package edu.mtu.citizenscience.streamapplication.activity;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import android.os.Bundle;
import android.app.Activity;
import android.text.Html;
import android.view.Menu;
import android.view.Window;

import android.os.Bundle;
import android.webkit.WebView;
import android.widget.TextView;
import android.app.Activity;

/**
 * @author Bryan Becker <bcbecker@mtu.edu>
 * @copyright (c) 2013 MichiganTech <http://www.mtu.edu>
 * 
 * HTML viewer activity. When a user clicks the question mark
 * on the custom header bar in any activity, the user will be
 * provided with a HTML help document. This class allows the
 * functionality to read any HTML when given the file path
 * of the HTML file in the assets folder.  
 */
public class HTMLView extends Activity {
	
	// reference var for passing the HTML file path between activities
	public static final String PATH = "PATH";
	
	private WebView webtest;
	private String myData;
	private String path;

	//custom header bar
	private TextView header;
	
	/**
	 * HTML View Activity creation handler
	 * 
	 * @param   savedInstanceState - Bundle - Bundle with launch info
	 * @return	void
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		//set the content view and enable the custom title
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.activity_htmlview);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
		
		//set the header text to "Help Documentation"
		header = (TextView) findViewById(R.id.header_text);
		header.setText("Help Documentation");

		//retrieve the file path for the HTML file to display
		path = this.getIntent().getStringExtra(this.PATH);
		
		//set up the webview variable by retrieving it by its id
		WebView webview = (WebView) findViewById(R.id.webview);
		
		//display the HTML file
		webview.loadUrl(path);
	}
	
}